Skip to content

fix(tasks): auto-wake assignee online on assignment/in_progress#302

Merged
abhi1693 merged 4 commits intoabhi1693:masterfrom
ailuvu-art:fix/assignee-auto-online-on-mission-start
Mar 20, 2026
Merged

fix(tasks): auto-wake assignee online on assignment/in_progress#302
abhi1693 merged 4 commits intoabhi1693:masterfrom
ailuvu-art:fix/assignee-auto-online-on-mission-start

Conversation

@ailuvu-art
Copy link
Contributor

Summary

This PR makes assignee liveness reflect active task operations.

When a task is assigned or moved into in_progress, Mission Control now performs a best-effort heartbeat commit (online) for the assignee, so operators do not need manual wake nudges.

Closes #301.

Changes

  • backend/app/api/tasks.py
    • Add _wake_agent_online_for_task(...) helper.
    • Call wake helper in assignment notification path (_notify_agent_on_task_assign).
    • Call wake helper when a task enters in_progress with an assignee (_notify_task_update_assignment_changes).
    • Record activity events:
      • task.assignee_woken
      • task.assignee_wake_failed

Why

Current behavior can show agents as offline even after assignment / mission start, which is confusing for task operators and makes mission kickoff feel unreliable.

Validation

Manual integration validation against local MC stack:

  1. Force assignee to offline via heartbeat endpoint.
  2. PATCH task with:
    • assigned_agent_id=<agent>
    • status=in_progress
  3. Confirm assignee status becomes online immediately after PATCH.

Also validated create-task-with-assignee path:

  • create task in inbox with assigned_agent_id set
  • assignee status transitions to online.

Notes

  • This is best-effort and non-blocking for task updates.
  • Existing agent notify flow remains intact.

@ailuvu-art
Copy link
Contributor Author

@abhi1693 Could you please review this fix?\n\nIt auto-wakes assignees to online when a task is assigned or moved to in_progress, to improve mission start reliability.\n\nIssue: #301\nPR: #302

@abhi1693 abhi1693 requested a review from Copilot March 19, 2026 11:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the backend task-mutation notification flow so that when a task is assigned or first enters in_progress, Mission Control best-effort “wakes” the assignee by committing an online heartbeat and recording activity events, reducing cases where the UI shows an assignee as offline during active work.

Changes:

  • Add _wake_agent_online_for_task(...) to commit an online heartbeat and record wake success/failure activity.
  • Invoke the wake helper during assignment notifications and when transitioning into in_progress with an assignee.
  • Add new activity events: task.assignee_woken and task.assignee_wake_failed.

@ailuvu-art
Copy link
Contributor Author

Addressed review feedback in commit dd5e6ef.

✅ Changes made

  1. Deduplicated wake path

    • Prevented double wake when one PATCH does both assignment + status transition to in_progress.
    • _notify_task_update_assignment_changes now wakes on status_in_progress only when assignment is unchanged.
    • Assignment path still wakes once via _notify_agent_on_task_assign.
  2. Reduced unnecessary board query

    • Reworked _notify_task_update_assignment_changes to lazy-load Board only when needed (unassign notify, wake, assign/rework notify paths).
  3. Added test coverage

    • test_lead_assignment_and_in_progress_wakes_assignee_once
      • Covers assignment + in_progress in one PATCH, asserts assignee wake happens once.
    • test_entering_in_progress_with_existing_assignee_wakes_assignee
      • Covers transition to in_progress with existing assignee, asserts wake + expected reason.

🔎 Manual verification

  • Rebuilt backend and verified with API smoke tests:
    • assignment + in_progress patch now emits exactly 1 task.assignee_woken event.
    • entering in_progress with existing assignee emits 1 wake event with (status_in_progress) reason.

The _lead_apply_status gate was too strict: it only permitted leads to
change task status when the task was already in .  This broke
the assignment-and-start shortcut introduced in the wake-assignee
feature, where a lead assigns a worker and simultaneously sets
 from .

Allow the transition  when the lead is also
supplying an  in the same PATCH.  All other
non-review status changes remain forbidden.

Fixes test_lead_assignment_and_in_progress_wakes_assignee_once.
@ailuvu-art
Copy link
Contributor Author

Hi @abhi1693 👋

PR check run #23306147068 is currently action_required (workflow approval needed for fork PR).

Please approve and run workflow for run 23306147068: https://github.com/abhi1693/openclaw-mission-control/actions/runs/23306147068

This is blocking because the latest push (commit 48bc1ea) needs a maintainer-approved run to verify the status-gate fix.

@abhi1693 abhi1693 merged commit 8bae49d into abhi1693:master Mar 20, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: assignees stay offline when task is assigned or moved to in_progress

3 participants